export default {
  computed: {
    currentGridView() {
      if (this.manager.states.tableIndex > -1) {
        return this.manager.Body.AllGridViews[this.manager.states.tableIndex];
      } else {
        return {};
      }
    },
    valCellType() {
      if (this.manager.states.visibleCells.length > 0) {
        let flag = this.manager.states.visibleCells.every(a => a.CellType === 'Textbox');
        if (flag) {
          return 'Textbox';
        }
        flag = this.manager.states.visibleCells.every(a => a.CellType === 'Image');
        if (flag) {
          return 'Image';
        }
        flag = this.manager.states.visibleCells.every(a => a.CellType === 'SubReport');
        if (flag) {
          return 'SubReport';
        }
      }
      return '';
    },
    valHeight() {
      if (this.manager.states.currentCell.RowIndex !== undefined) {
        return this.currentGridView.Rows[this.manager.states.currentCell.RowIndex].Height;
      }
      return 0;
    },
    valWidth() {
      if (this.manager.states.currentCell.RowIndex !== undefined) {
        return this.currentGridView.Columns[this.manager.states.currentCell.ColumnIndex].Width;
      }
      return 0;
    },

    isBorderLeft() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.BorderLeftLineStyle !== 'None');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isBorderRight() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.BorderRightLineStyle !== 'None');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isBorderTop() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.BorderTopLineStyle !== 'None');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isBorderBottom() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.BorderBottomLineStyle !== 'None');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignLeft() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.TextAlign === 'Left');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignCenter() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.TextAlign === 'Center');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignRight() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.TextAlign === 'Right');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignTop() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.VerticalAlign === 'Top');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignMiddle() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.VerticalAlign === 'Middle');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isAlignBottom() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.VerticalAlign === 'Bottom');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isFontBold() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.FontBold);
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isFontItalic() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.FontItalic);
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isFontStrikeout() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.FontStrikeout);
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isFontUnderline() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.FontUnderline);
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    isWritingMode() {
      if (this.manager.states.visibleCells.length > 0) {
        const flag = this.manager.states.visibleCells.every(a => a.WritingMode === 'Vertical');
        if (flag) {
          return 'primary';
        }
      }
      return 'default';
    },
    FontName() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].FontName;
      }
      return '宋体';
    },
    FontSize() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].FontSize;
      }
      return 12;
    },
    ForeColor() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].ForeColor;
      }
      return '#000000';
    },
    BackColor() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].BackColor;
      }
      return '#ffffff';
    },
    IDValueOfImage() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].Text;
      }
      return '';
    },
    ImageName() {
      if (this.manager.states.visibleCells.length > 0) {
        return this.manager.states.visibleCells[0].ImageName;
      }
      return '';
    },
    BorderLeftLineStyle() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderLeftLineStyle';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return first;
        }
      }
      return '';
    },
    BorderLeftWidth() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderLeftWidth';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return Number(first);
        }
      }
      return 1;
    },
    BorderTopLineStyle() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderTopLineStyle';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return first;
        }
      }
      return '';
    },
    BorderTopWidth() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderTopWidth';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return Number(first);
        }
      }
      return 1;
    },
    BorderRightLineStyle() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderRightLineStyle';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return first;
        }
      }
      return '';
    },
    BorderRightWidth() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderRightWidth';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return Number(first);
        }
      }
      return 1;
    },
    BorderBottomLineStyle() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderBottomLineStyle';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return first;
        }
      }
      return '';
    },
    BorderBottomWidth() {
      if (this.manager.states.visibleCells.length > 0) {
        const attr = 'BorderBottomWidth';
        const first = this.manager.states.visibleCells[0][attr];
        const flag = this.manager.states.visibleCells.every(a => a[attr] === first);
        if (flag) {
          return Number(first);
        }
      }
      return 1;
    },
  },
};
